import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:keep_account/vm/user_login_controller.dart';

class UserLogin extends StatefulWidget {
  const UserLogin({super.key});
  @override
  State<StatefulWidget> createState() => _UserLoginState();

}

class _UserLoginState extends State<UserLogin> {

  late final UserLoginController _controller = Get.put(UserLoginController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("登录"),),
      body: SingleChildScrollView(
        padding: const EdgeInsets.only(top: 80,left: 15,right: 15),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              alignment: Alignment.centerLeft,
              width: double.infinity,
              margin: const EdgeInsets.only(left: 15),
              child: const Text("登录",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w700),),
            ),
            Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  width: double.infinity,
                  height: 65,
                  alignment: Alignment.center,
                  padding: const EdgeInsets.only(left: 10),
                  margin: const EdgeInsets.only(top: 20,left: 10,right: 10),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(5),
                      boxShadow: [
                        BoxShadow(
                            color: Colors.black.withOpacity(0.1),
                            blurRadius: 10
                        )
                      ]
                  ),
                  child: TextFormField(
                    keyboardType: TextInputType.number,
                    style: const TextStyle(fontSize: 20),
                    autovalidateMode: AutovalidateMode.onUserInteraction,
                    decoration: const InputDecoration(hintText: "请输入手机号",border: InputBorder.none,labelStyle: TextStyle(fontSize: 18),hintStyle: TextStyle(fontSize: 18)),
                    controller: _controller.phoneController,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 40,left: 10,right: 10),
                  child: SizedBox(
                    width: double.infinity,
                    height: 55,
                    child: ElevatedButton(
                        onPressed: ()=>_controller.login(),
                        child: const Text("登录",style: TextStyle(fontSize: 20),)
                    ),
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 40,left: 10,right: 10),
                  child: SizedBox(
                    width: double.infinity,
                    height: 55,
                    child: ElevatedButton(
                        onPressed: ()=>_controller.registerAndLogin(),
                        child: const Text("注册并登录",style: TextStyle(fontSize: 20),)
                    ),
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }

}